import Vue from 'vue';
import App from './App.vue';

import router from './router'
import store from './store'
import * as echarts from 'echarts'
import Router from 'vue-router'
import 'element-ui/lib/theme-chalk/index.css';
import './assets/css/global.less'
import 'amfe-flexible'
import './utils/res'

import moment from 'moment'
Vue.prototype.$moment = moment

import ElementUI from 'element-ui';
Vue.use(ElementUI);
// Vue.use(CommonComponent)
// Vue.use(MainComponent)

import VueCookies from 'vue-cookies';
Vue.use(VueCookies)

Vue.prototype.echarts = echarts;
Vue.config.productionTip = false;

// 将自动注册所有组件为全局组件
import dataV from '@jiaminghi/data-view';
Vue.use(dataV);



Vue.directive('enterNumber', {
  inserted: function (el) {
    el.addEventListener("keypress", function (e) {
      e = e || window.event;
      let charcode = typeof e.charCode == 'number' ? e.charCode : e.keyCode;
      let re = /\d/;
      if (!re.test(String.fromCharCode(charcode)) && charcode > 9 && !e.ctrlKey) {
        if (e.preventDefault) {
          e.preventDefault();
        } else {
          e.returnValue = false;
        }
      }
    });
  }
});
new Vue({
  // router,
  router,
  store,
  render: h => h(App),
}).$mount('#app');
const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
  // console.log('location', location)  // 这块可以打印出来你当前路径
  return originalPush.call(this, location).catch(err => err)
}